Skip to content

Fix page links returning 404 in server mode#1671

Open
st0012 wants to merge 2 commits intomasterfrom
fix-server-pages-404
Open

Fix page links returning 404 in server mode#1671
st0012 wants to merge 2 commits intomasterfrom
fix-server-pages-404

Conversation

@st0012
Copy link
Copy Markdown
Member

@st0012 st0012 commented Apr 4, 2026

Summary

  • TopLevel#parser= was passing absolute_name to Store#update_parser_of_file, but @files_hash is keyed by relative_name. The lookup always failed, so @text_files_hash was never populated and find_text_page always returned nil — making every page link in the sidebar 404.
  • Changed the call to pass relative_name instead, and renamed the parameter in update_parser_of_file for consistency.
  • Added a unit test for the deferred-parser path and integration tests for server page routing.

st0012 added 2 commits April 4, 2026 01:20
`TopLevel#parser=` was calling `update_parser_of_file` with
`absolute_name`, but `@files_hash` is keyed by `relative_name`.
The lookup always failed, so `@text_files_hash` was never populated
and `find_text_page` always returned nil.
These tests exercise the full pipeline: parsing source files, then
resolving page URLs through the server's route method. They verify
that text pages (.md, .rdoc), class pages, the index, and 404s all
work correctly. The text page tests would have caught the
update_parser_of_file key mismatch bug.
@matzbot
Copy link
Copy Markdown
Collaborator

matzbot commented Apr 4, 2026

🚀 Preview deployment available at: https://c9681a98.rdoc-6cd.pages.dev (commit: de0e722)

@st0012 st0012 added the bug label Apr 4, 2026
@st0012 st0012 marked this pull request as ready for review April 4, 2026 11:58
@kou kou requested a review from Copilot April 8, 2026 14:21
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes server-mode sidebar page links returning 404 by ensuring text pages are indexed using relative_name (matching @files_hash keys), and adds regression coverage for deferred parser assignment and server routing.

Changes:

  • Pass relative_name (not absolute_name) from RDoc::TopLevel#parser= into RDoc::Store#update_parser_of_file.
  • Rename update_parser_of_file parameter for consistency with store keying.
  • Add unit + integration tests covering deferred parser assignment and server route behavior for pages/classes/index/404.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
lib/rdoc/code_object/top_level.rb Updates parser assignment to notify the store using relative_name so text pages get indexed correctly.
lib/rdoc/store.rb Aligns update_parser_of_file API/behavior with @files_hash keying (relative paths).
test/rdoc/rdoc_store_test.rb Adds regression test for the deferred-parser path to ensure find_text_page works post-parser=.
test/rdoc/rdoc_server_test.rb Adds routing tests to verify server-mode correctly serves pages/classes/index and returns 404 for missing pages.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +324 to +328
# Sets the parser of +relative_name+, unless it from a source code file.

def update_parser_of_file(absolute_name, parser)
if top_level = @files_hash[absolute_name] then
@text_files_hash[absolute_name] = top_level if top_level.text?
def update_parser_of_file(relative_name, parser)
if top_level = @files_hash[relative_name] then
@text_files_hash[relative_name] = top_level if top_level.text?
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method comment is inaccurate/grammatically incorrect: update_parser_of_file does not “set the parser”, it only updates @text_files_hash based on top_level.text? (and the sentence is missing “is”: “unless it is from ...”). Also, the parser parameter is unused; consider removing it or renaming to _parser to make the intent clear.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member

@kou kou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants